package com.masterclient.app.modules.aftersale.contract;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.ThrowableConsumer;
import com.eoner.baselibrary.bean.aftersale.ExpressBean;
import com.masterclient.app.httpservice.RetrofitUtil2;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/26
*/
public class LogistPresenter extends LogistContract.Presenter{

    @Override
    public void getTrackDetail(String order_id,String track_no,String biz_type) {

        Observable<CommonBaseResponse<ExpressBean>> observable = RetrofitUtil2.getInstance().getTrackDetail(order_id,track_no,biz_type);
        Disposable disposable = toSubscribe(observable, new Consumer<CommonBaseResponse<ExpressBean>>() {
            @Override
            public void accept(@NonNull CommonBaseResponse<ExpressBean> bean) throws Exception {
                if(bean.getCode() == 0){
                    mView.getTrackDetail(bean.getData());
                }else {

                }
            }
        }, new ThrowableConsumer(){
            @Override
            public void accept(Throwable o) throws Exception {
                super.accept(o);
            }
        });
        mRxManager.add(disposable);
    }
}